package com.budwk.app.sqfw.controllers.admin.customservice;

import com.budwk.app.sqfw.services.customservice.ComDataStatisticsService;
import com.budwk.app.sqfw.vo.SqfwCustomForAdminCommonVO;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;

import javax.servlet.http.HttpServletResponse;

/**
 * @program: dfxy-community
 * @description: 社区数据统计控制器
 * @author: LJT
 * @create: 2024-07-16 15:56
 **/
@IocBean
@At("/platform/sqfw/ComDataStatistics")
@ApiDefinition(tag = "社区数据统计（后台管理系统）")
@Slf4j
public class ComDataStatisticsForAdminController {

    @Inject
    private ComDataStatisticsService comDataStatisticsService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "社区和用户数据统计")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwCustomForAdminCommonVO.class
    )
    @ApiResponses(
            implementation = SqfwCustomForAdminCommonVO.class
    )
    @SLog(value = "社区数据统计（后台管理系统）")
//    @SaCheckLogin
    public Result<?> pageForSummaryUser(@Param("..") SqfwCustomForAdminCommonVO bean) {
        return Result.data(comDataStatisticsService.pageForSummaryUser(bean));
    }

    @At
    @Ok("void")
    @POST
    @SLog(value = "导出数据")
    @ApiOperation(name = "导出数据")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwCustomForAdminCommonVO.class
    )
    @ApiResponse
//    @SaCheckLogin
    public void export(@Param("..") SqfwCustomForAdminCommonVO bean, HttpServletResponse response) {
        comDataStatisticsService.exportForSummaryUser(bean, response);
    }
}
